/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFSource
  \brief the base class of ETFOnlineSource and ETFOfflineSource
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2023-06-26
  \date 2021-06-26 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2023-06-26   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFSource_h
#define ETFSource_h

#include <vector>
#include <string>

using std::vector;
using std::string;

class ETFUnpacker;

class ETFSource{
public:
  ETFSource();
  virtual ~ETFSource();

  virtual void Init(); ///< initialize the unpackers
  virtual bool ReadEvent(unsigned ev = 0) = 0; ///< true: success
  virtual void Close() = 0; ///< close the input file
  virtual bool IsClean() const{ return false; } ///< only valid for ETFOnlineSource
  virtual void PrintSummary(); ///< print unpacking summary
  virtual void SetDebug(bool opt = true){} ///< set unpacker debug status
  virtual const char *ROOTFileName() const{ return fROOTFileName.data(); }
  virtual int GetNofUnpackers() const{ return fUpks.size(); }
  const vector<ETFUnpacker *> upks() const{ return fUpks; }
  virtual unsigned CntEv() const{ return fEventCnt; }

  // ClassDef(ETFSource, 0); ///< to process offline data

protected:
  unsigned fEventCnt; ///< nof unpacked events
  bool fUnpackGood; ///< true: good; false: bad
  vector<ETFUnpacker *> fUpks; ///< list of unpackers
  string fROOTFileName; ///< the output rootfile name
};

#endif
